package com.one.friend.controller.exam;

import com.one.common.core.controller.BaseController;
import com.one.common.core.domain.R;
import com.one.common.core.domain.TableDataInfo;
import com.one.friend.domain.exam.dto.ExamQueryDTO;
import com.one.friend.domain.exam.dto.ExamRankDTO;
import com.one.friend.service.exam.IExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
public class ExamController extends BaseController {

    @Autowired
    private IExamService iExamService;

    /**
     *      接口概述  竞赛列表功能
     *      接口地址  /exam/semiLogin/list
     *      请求方法  get
     *      请求参数  ExamQueryDTO
     *      响应数据  TableDataInfo
     */
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return getTableDataInfo(iExamService.list(examQueryDTO));
    }

    @GetMapping("/semiLogin/redis/list")
    public TableDataInfo redisList(ExamQueryDTO examQueryDTO){
        return iExamService.redisList(examQueryDTO);
    }

    @GetMapping("/rank/list")
    public TableDataInfo rankList(ExamRankDTO examRankDTO) {
        return iExamService.rankList(examRankDTO);
    }

    //获取竞赛当中第一题的详情信息
    @GetMapping("/getFirstQuestion")
    public R<String> getFirstQuestion(Long examId){
        return R.ok(iExamService.getFirstQuestion(examId));
    }

    //竞赛当中切换上下题
    @GetMapping("/examPreQuestion")
    public R<String> examPreQuestion(Long examId, Long questionId){
        return R.ok(iExamService.examPreQuestion(examId,questionId));
    }

    @GetMapping("/examNextQuestion")
    public R<String> examNextQuestion(Long examId,Long questionId){
        return R.ok(iExamService.examNextQuestion(examId,questionId));
    }
}
